﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WodLib.Controls
{
    public partial class MoralityEditorForm : Form
    {
        private HumanMorality morality;

        public MoralityEditorForm(HumanMorality morality)
        {
            this.morality = morality;
            InitializeComponent();
        }

        private int RemapLevelToIndex(int level)
        {
            return 10 - level;
        }

        private void trackBarMoralityLevel_ValueChanged(object sender, EventArgs e)
        {
            morality.Level = trackBarMoralityLevel.Value;
            labelLevel.Text = morality.Level.ToString();
        }

        private void buttonSet_Click(object sender, EventArgs e)
        {
            morality.Derangements[RemapLevelToIndex(morality.Level)]
                = textBoxDerangement.Text;
            listBoxDerangements.Items[RemapLevelToIndex(morality.Level)]
                = textBoxDerangement.Text;
        }

        private void MoralityEditorForm_Load(object sender, EventArgs e)
        {
            listBoxDerangements.Items.Clear();
            listBoxDerangements.Items.AddRange(morality.Derangements);
            trackBarMoralityLevel.Value = morality.Level;
        }
    }
}
